package com.mall.seckil.controller;

import com.mall.common.utils.Result;
import com.mall.seckil.dto.SeckillSkuRedisDto;
import com.mall.seckil.service.SeckillService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 谢君臣
 * @Date: 2022/9/19-13:27
 * @version: 1.0
 * @function:
 */
@RestController
@Api("秒杀控制")
@RequestMapping("/seckill/session")
public class SeckillSessionController {

    @Resource
    private SeckillService seckillService;
    @GetMapping("/curr/seckill")
    public Result<List<SeckillSkuRedisDto>> getCurrentSeckill(){
        List<SeckillSkuRedisDto> list = seckillService.getCurrentSession();
        return new Result<List<SeckillSkuRedisDto>>().ok(list);
    }
    @GetMapping("/info/{skuId}")
    public Result<SeckillSkuRedisDto> getSkuSeckillInfo(@PathVariable("skuId")Long skuId){
      SeckillSkuRedisDto info = seckillService.getSkuSeckillInfo(skuId);
      return new Result<SeckillSkuRedisDto>().ok(info);
    }
}
